<?php
namespace app\index\Validate;


use think\Validate;

class TradeValidate extends Validate
{
    protected $rule = [
        'amount'=>'require|checkAmount',
        'coin_id'=>'require',
        'market_id'=>'require',
    ];

    protected $message = [
        'amount.require'=>'金额必填',
        'amount.checkAmount'=>'金额必须是数字',
        'coin_id.require'=>'钱包必须选择',
        'market_id.require'=>'交易对必须选择',
    ];
    public function checkAmount($value)
    {
        $value = floatval($value);
        if (!is_numeric($value)) {
            return false;
        }
        if ($value<0) {
            return false;
        }
        return true;
    }
}